package com.example.serveraidl;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

import com.example.server_aidl.IRemoteService;
import com.example.server_aidl.Rect;

public class RemoteService extends Service {
    private final String TAG = "RemoteService";

    public RemoteService() {
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d(TAG, "onCreate()");
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.d(TAG, "onBind()");
        return binder;
    }

    private final IRemoteService.Stub binder = new IRemoteService.Stub() {
        @Override
        public void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat, double aDouble, String aString) throws RemoteException {
            Log.d(TAG, "basicTypes: anInt: " + anInt);
            Log.d(TAG, "basicTypes: aLong: " + aLong);
            Log.d(TAG, "basicTypes: aBoolean: " + aBoolean);
            Log.d(TAG, "basicTypes: aFloat: " + aFloat);
            Log.d(TAG, "basicTypes: aDouble: " + aDouble);
            Log.d(TAG, "basicTypes: aString: " + aString);
        }

        //实现addRectInOut，接受Rect对象
        @Override
        public void addRectInOut(Rect rect) throws RemoteException {
            Log.d(TAG, "addRectInOut:" + rect.toString());
        }
    };
}